﻿using System.Collections.Generic;
using System.Text;
using UnityEngine.UI;

namespace WzhModule.GM
{
    [UnityEngine.Scripting.Preserve]
    [WzhGMClass("基本信息", 98)]
    public class InfoDebugMenu : WzhGMMenu
    {
        [WzhGMLabel("渠道ID")] public string Label1;
        [WzhGMLabel("渠道标识符")] public string Label_GetAppChannel;
        [WzhGMLabel("应用程序包名")] public string Label2;
        [WzhGMLabel("当前版本号")] public string Label3;
        [WzhGMLabel("安装版本号")] public string Label4;
        [WzhGMLabel("是否是安装版本")] public string Label5;
        [WzhGMLabel("设备id")] public string Label6;
        [WzhGMLabel("地区")] public string Label7;
        [WzhGMLabel("App发布地区(0:国内，1海外，2国际版)")] public string Label8;
        [WzhGMLabel("设备信息")] public string Label9;
        [WzhGMLabel("测试模式")] public string Label10;
        [WzhGMLabel("默认语言")] public string Label11;
        [WzhGMLabel("当前语言")] public string Label12;
        [WzhGMLabel("实际分辨率")] public string Label13;
        [WzhGMLabel("设计分辨率")] public string Label14;

        public override void Init()
        {
            base.Init();

            //Label1 = AppInfoManager.Instance.GetAppChannelId().ToString();
            //Label_GetAppChannel = AppInfoManager.Instance.GetAppChannel();
            //Label2 = AppInfoManager.Instance.GetPackageName();//.ToString();
            //Label3 = AppInfoManager.Instance.GetVersionName();//.ToString();
            //Label4 = AppInfoManager.Instance.GetInstallVersion();//.ToString();
            //Label5 = AppInfoManager.Instance.IsInstallVersion().ToString();
            //Label6 = AppInfoManager.Instance.GetDeviceId();//.ToString();
            //Label7 = GetDeviceRegion();
            //Label8 = AppInfoManager.Instance.GetPublishCountryCode().ToString();
            //Label9 = AppInfoManager.Instance.GetPhoneInfo();//.ToString();
            //SetAppDebugStatic(null);
            //Label11 = GlobalData.appDefaultLangType.ToString();
            //Label12 = GameFrameEntry.GetModule<LangModule>().LangType.ToString();
            //StringBuilder stb = new StringBuilder();
            //stb.Append(AppInfoManager.Instance.GetScreenWidth()).Append("X").Append(AppInfoManager.Instance.GetScreenHeight());
            //Label13 = stb.ToString();
            //if (GameFrameEntry.GetModule<UIModule>() != null && GameFrameEntry.GetModule<UIModule>().canvas != null)
            //{
            //    var CanvasScaler = GameFrameEntry.GetModule<UIModule>().Canvas.GetComponent<CanvasScaler>();
            //    stb.Length = 0;
            //    stb.Append(CanvasScaler.referenceResolution.x).Append("X").Append(CanvasScaler.referenceResolution.y);
            //    Label14 = stb.ToString();
            //}

            //MsgDispatcher.AddEventListener("GM.AppChangeTestMode", SetAppDebugStatic);
        }


        public void SetAppDebugStatic(object[] param)
        {
            //Label10 = SDKToolManager.Instance.GetAppDebugStatic(1) == 1 ? "测试模式" : "正式模式";

        }

        /// <summary>获取用户所在的地区</summary>
        public string GetDeviceRegion()
        {
            string region = "";

            Dictionary<int, string> dicRegion = new Dictionary<int, string>();
            dicRegion[0] = "国内";
            dicRegion[1] = "google play";
            dicRegion[100] = "中国大陆";
            dicRegion[101] = "中国港澳台地区";
            dicRegion[102] = "日本";
            dicRegion[103] = "美国";
            dicRegion[104] = "印度";
            dicRegion[105] = "巴西";
            dicRegion[106] = "墨西哥";
            dicRegion[107] = "韩国";
            dicRegion[108] = "法国";
            dicRegion[109] = "菲律宾";
            dicRegion[110] = "塞内加尔";
            dicRegion[111] = "委内瑞拉";
            dicRegion[112] = "阿根廷";
            dicRegion[113] = "喀麦隆";
            dicRegion[114] = "西班牙";
            dicRegion[115] = "加拿大";
            dicRegion[116] = "德国";
            dicRegion[117] = "英国";
            dicRegion[118] = "意大利";
            dicRegion[999] = "其他";

            //int DeviceLocal = AppInfoManager.Instance.GetDeviceLocalStatic();
            //if (dicRegion.ContainsKey(DeviceLocal))
            //{
            //    region = dicRegion[DeviceLocal];
            //}
            //else
            //{
            //    StringBuilder stb = new StringBuilder();
            //    stb.Append("未找到：").Append(DeviceLocal.ToString());
            //    region = stb.ToString();
            //}
            return region;
        }

        public override void OnDispose()
        {
            //MsgDispatcher.RemoveEventListener("GM.AppChangeTestMode", SetAppDebugStatic);

        }
    }
}